package com.hardy.demo.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * Author: Hardy
 * Date:   2021/3/11
 * Description:
 **/
public class CglibProxyUserOption implements MethodInterceptor {

    @Override
    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        System.out.println("调用之前：" + proxy.getClass().getName() + "::" + method.getName());
        Object result = methodProxy.invokeSuper(proxy, args);
        System.out.println("调用之后：" + proxy.getClass().getName() + "::" + method.getName());
        System.out.println("-------------------------------------");
        return result;
    }
}
